/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.pucp.Maestros.Vista; 

import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.JFrame;
import pe.edu.pucp.Modelo.Continente;
import pe.edu.pucp.Modelo.Permiso;
import pe.edu.pucp.Util.ValHelper;
import sigepa.MainController.ValidaCarga;
/**
 *
 * @author katy
 */
public class CargaXMLGUI extends javax.swing.JPanel {

    Continente c;
    static JFrame ventana;  
    Boolean cargado;
    public ValidaCarga vc;
    
    
    public CargaXMLGUI(ValidaCarga pvc) {

        initComponents();
        vc=pvc;
        if(!vc.cargado){
            this.btnAbrirDInicial.setEnabled(true);
            this.btnCargarDInicial.setEnabled(true);
            this.btnAbrirDVuelo.setEnabled(false);
            this.btnCargarDVuelo.setEnabled(false);
            this.btnAbrirDSimulacion.setEnabled(false);
            this.btnCargarDSimulacion.setEnabled(false);
        }
        else{
            this.btnAbrirDInicial.setEnabled(false);
            this.btnCargarDInicial.setEnabled(false);
            this.btnAbrirDVuelo.setEnabled(false);
            this.btnCargarDVuelo.setEnabled(false);
            this.btnAbrirDSimulacion.setEnabled(false);
            this.btnCargarDSimulacion.setEnabled(false);
            
        }
    }
    
    public void addCargarDatosInicialesListener(ActionListener listener){
        this.btnCargarDInicial.addActionListener(listener);
    }
    
    public void addCargarVueloListener(ActionListener listener){
        this.btnCargarDVuelo.addActionListener(listener);
    }
    
    public void addCargarDatosSimulacionlistener(ActionListener listener){
        this.btnCargarDSimulacion.addActionListener(listener);
    } 
            
    public void addBuscarVueloListener(ActionListener listener){
      
       this.btnAbrirDVuelo.addActionListener(listener);
    }
    
    public void addBuscarDatosInicialesListener(ActionListener listener){
      
       this.btnAbrirDInicial.addActionListener(listener);
    }
    
    public void addBuscarDatosSimulacionListener(ActionListener listener){
        this.btnAbrirDSimulacion.addActionListener(listener);
    }
    
    public void mostrarPermisos(ArrayList<Permiso> list){            
//        if (!list.isEmpty()){                                
//            btnAbrirDInicial.setEnabled(buscarPermiso(list,Constante.P_ADM_CARM_ABRIR)==1);
//            btnAbrirDSimulacion.setEnabled(buscarPermiso(list,Constante.P_ADM_CARM_ABRIR)==1);
//            btnAbrirDVuelo.setEnabled(buscarPermiso(list,Constante.P_ADM_CARM_ABRIR)==1);
//            btnCargarDInicial.setEnabled(buscarPermiso(list,Constante.P_ADM_CARM_CARGAR)==1);
//            btnCargarDSimulacion.setEnabled(buscarPermiso(list,Constante.P_ADM_CARM_CARGAR)==1);
//            btnCargarDVuelo.setEnabled(buscarPermiso(list,Constante.P_ADM_CARM_CARGAR)==1);
//             
//        }
    }    
  
    public int buscarPermiso(ArrayList<Permiso> list, int idel){
        int per=-1;
        for (Permiso opc : list){
            if (opc.getElemento().getIdelemento()==idel){ per =opc.getPermiso(); }
        }
        return per;
    }      
    
       
    public void setNombreArchivoVuelo(String fileName) {
        this.txtNombreArchivoVuelo.setText(fileName);
    }
    
    public void setNombreArchivoDatosIniciales(String fileName) {
        this.txtNombreArchivoDatosIniciales.setText(fileName);
    }
    
    public void setNombreArchivoDatosSimulacion(String fileName){
        this.txtNombreArchivoDatosSimulacion.setText(fileName);
    }

    public String getNombreArchivoVuelo() {
        return this.txtNombreArchivoVuelo.getText();
    }
    
    public String getNombreArchivoDatosIniciales() {
        return this.txtNombreArchivoDatosIniciales.getText();
    }
    
     public String getNombreArchivoDatosSimulacion(){
        return this.txtNombreArchivoDatosSimulacion.getText();
    }
    
    public void mostrarError(String msn){
        ValHelper.mostrarError(msn);           
    }
    
    public void mostrarConformidad(String msj){
        ValHelper.mostrarAviso(msj);
    }

    public javax.swing.JButton getbtnAbrirDInicial()
    {
        return btnAbrirDInicial;
    }
    
    public javax.swing.JButton getbtnCargarDInicial()
    {
        return btnCargarDInicial;
    }
    
    public javax.swing.JButton getbtnAbrirDVuelo()
    {
        return btnAbrirDVuelo;
    }
    
    public javax.swing.JButton getbtnCargarDVuelo()
    {
        return btnCargarDVuelo;
    }
    
    public javax.swing.JButton getbtnAbrirDSimulacion()
    {
        return btnAbrirDSimulacion;
    }
    
    public javax.swing.JButton getbtnCargarDSimulacion()
    {
        return btnCargarDSimulacion;
    }
    
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel7 = new javax.swing.JPanel();
        btnAbrirDInicial = new javax.swing.JButton();
        txtNombreArchivoDatosIniciales = new javax.swing.JTextField();
        btnCargarDInicial = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        lblMensaje = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jPanel12 = new javax.swing.JPanel();
        btnAbrirDVuelo = new javax.swing.JButton();
        txtNombreArchivoVuelo = new javax.swing.JTextField();
        btnCargarDVuelo = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        lblMensaje1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jPanel13 = new javax.swing.JPanel();
        btnAbrirDSimulacion = new javax.swing.JButton();
        txtNombreArchivoDatosSimulacion = new javax.swing.JTextField();
        btnCargarDSimulacion = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        lblMensaje2 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();

        setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        setMaximumSize(new java.awt.Dimension(764, 700));
        setMinimumSize(new java.awt.Dimension(764, 700));

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Iniciales"));

        btnAbrirDInicial.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recurso/folder.png"))); // NOI18N
        btnAbrirDInicial.setToolTipText("Seleccionar carpeta");

        txtNombreArchivoDatosIniciales.setEditable(false);

        btnCargarDInicial.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recurso/checkmark.png"))); // NOI18N
        btnCargarDInicial.setToolTipText("Cargar Archivo XML");

        jLabel1.setText("Seleccione los archivos de carga de aeropuertos y tipo de aviones.");

        lblMensaje.setForeground(new java.awt.Color(246, 17, 17));
        lblMensaje.setText("La carpeta a ingresar debe tener los archivos: usuario.xml, password.xml y aeropuerto.xml");

        jLabel4.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel4.setForeground(java.awt.Color.gray);
        jLabel4.setText("Archivo XML:");

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 580, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(26, 26, 26)
                        .addComponent(txtNombreArchivoDatosIniciales, javax.swing.GroupLayout.PREFERRED_SIZE, 460, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(25, 25, 25)
                        .addComponent(btnAbrirDInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnCargarDInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(lblMensaje, javax.swing.GroupLayout.PREFERRED_SIZE, 630, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addComponent(jLabel1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(49, 49, 49)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtNombreArchivoDatosIniciales, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4)))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(37, 37, 37)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btnAbrirDInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnCargarDInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
                .addComponent(lblMensaje)
                .addGap(9, 9, 9))
        );

        jPanel12.setBorder(javax.swing.BorderFactory.createTitledBorder("Vuelos programados"));
        jPanel12.setEnabled(false);

        btnAbrirDVuelo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recurso/folder.png"))); // NOI18N
        btnAbrirDVuelo.setToolTipText("Seleccionar archivo");

        btnCargarDVuelo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recurso/checkmark.png"))); // NOI18N
        btnCargarDVuelo.setToolTipText("Cargar Archivo XML");

        jLabel2.setText("Seleccione los archivos de carga de vuelos.");

        lblMensaje1.setForeground(new java.awt.Color(246, 17, 17));
        lblMensaje1.setText("Archivo a ingresar: Vuelo.xml");

        jLabel3.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel3.setForeground(java.awt.Color.gray);
        jLabel3.setText("Archivo XML:");

        txtNombreArchivoVuelo.setEditable(false);

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(27, 27, 27)
                        .addComponent(txtNombreArchivoVuelo, javax.swing.GroupLayout.PREFERRED_SIZE, 460, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(24, 24, 24)
                        .addComponent(btnAbrirDVuelo, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnCargarDVuelo, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 580, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblMensaje1, javax.swing.GroupLayout.PREFERRED_SIZE, 604, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel12Layout.createSequentialGroup()
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btnAbrirDVuelo, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnCargarDVuelo, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(4, 4, 4))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel12Layout.createSequentialGroup()
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtNombreArchivoVuelo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                        .addGap(12, 12, 12)))
                .addComponent(lblMensaje1))
        );

        jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder("Vuelos programados"));
        jPanel13.setEnabled(false);

        btnAbrirDSimulacion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recurso/folder.png"))); // NOI18N
        btnAbrirDSimulacion.setToolTipText("Seleccionar archivo");

        btnCargarDSimulacion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recurso/checkmark.png"))); // NOI18N
        btnCargarDSimulacion.setToolTipText("Cargar Archivo XML");

        jLabel5.setText("Seleccione los archivos de carga de clientes, viajes y paquetes.");

        lblMensaje2.setForeground(new java.awt.Color(246, 17, 17));
        lblMensaje2.setText("La carpeta a ingresar debe tener los archivos: cliente.xml, envio.xml y paquete.xml");

        jLabel6.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel6.setForeground(java.awt.Color.gray);
        jLabel6.setText("Archivo XML:");

        txtNombreArchivoDatosSimulacion.setEditable(false);

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel13Layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addGap(29, 29, 29)
                        .addComponent(txtNombreArchivoDatosSimulacion, javax.swing.GroupLayout.PREFERRED_SIZE, 458, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(24, 24, 24)
                        .addComponent(btnAbrirDSimulacion, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnCargarDSimulacion, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 580, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblMensaje2, javax.swing.GroupLayout.PREFERRED_SIZE, 604, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel13Layout.createSequentialGroup()
                        .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btnAbrirDSimulacion, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnCargarDSimulacion, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(4, 4, 4))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel13Layout.createSequentialGroup()
                        .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtNombreArchivoDatosSimulacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6))
                        .addGap(12, 12, 12)))
                .addComponent(lblMensaje2))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(293, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAbrirDInicial;
    private javax.swing.JButton btnAbrirDSimulacion;
    private javax.swing.JButton btnAbrirDVuelo;
    private javax.swing.JButton btnCargarDInicial;
    private javax.swing.JButton btnCargarDSimulacion;
    private javax.swing.JButton btnCargarDVuelo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JLabel lblMensaje;
    private javax.swing.JLabel lblMensaje1;
    private javax.swing.JLabel lblMensaje2;
    private javax.swing.JTextField txtNombreArchivoDatosIniciales;
    private javax.swing.JTextField txtNombreArchivoDatosSimulacion;
    private javax.swing.JTextField txtNombreArchivoVuelo;
    // End of variables declaration//GEN-END:variables
}
